/*
 * common.h
 *
 *  Created on: 2011-4-14
 *      Author: cchao
 */

#ifndef G_COMMON_H_
#define G_COMMON_H_

#define MAX_LANE_COUNT 4
#define MAX_LAMP_COUNT 8

#define ITEM_TYPE_POINT 1
#define ITEM_TYPE_LINE 2
#define ITEM_TYPE_RECT 3
#define ITEM_TYPE_POLYGON 4

#define INI_PATH "."

enum WORK_STATE			// 部件状态
{
	WORK_STATE_NULL 		= 0,
	WORK_STATE_NORMAL		= 1,		// 正常状态
	WORK_STATE_EXCEPTION	= 2			// 异常状态
};

enum LAMP_DETECTOR_TYPE
{
	LAMP_DETECTOR_TYPE_NONE = 0,	// 视频检测
	LAMP_DETECTOR_TYPE_KISE = 1,	// 凯智红绿灯检测器
	LAMP_DETECTOR_TYPE_DFA = 2		// 迪菲亚红绿灯检测器
};

enum CONFIG				// 配置项
{
	CONFIG_NONE    = 0,
	CONFIG_SYS     = 0x1,
	CONFIG_UNIT    = 0x1 << 1,
	CONFIG_LAMP    = 0x1 << 2,
	CONFIG_CAMERA  = 0x1 << 3,
	CONFIG_EVENTER = 0x1 << 4,
	CONFIG_RECO    = 0x1 << 5,
	CONFIG_VREC    = 0x1 << 6,
	CONFIG_TEXT    = 0x1 << 7,
	CONFIG_REPORT  = 0x1 << 8,
	CONFIG_SWITCH  = 0x1 << 9
};

enum CAMERA_CTRL
{
	CAMERA_CTRL_NONE = 0,
	CAMERA_CTRL_IMAGE_FPS		= 1,
	CAMERA_CTRL_IMAGE_WIDTH		= 2,
	CAMERA_CTRL_IMAGE_HEIGHT		= 3,
	CAMERA_CTRL_VIDEO_FPS		= 4,
	CAMERA_CTRL_VIDEO_WIDTH		= 5,
	CAMERA_CTRL_VIDEO_HEIGHT		= 6,
	CAMERA_CTRL_VIDEO_RATE		= 7,
	CAMERA_CTRL_AGC_BASELINE		= 8,
	CAMERA_CTRL_MAX_AGC_GAIN		= 9,
	CAMERA_CTRL_MAX_AGC_TIME		= 10,
	CAMERA_CTRL_MAX
};

enum COMPONENT_ID			// 组件ID
{
	COMPONENT_ID_LAMP    = 0, 			// 信号灯
	COMPONENT_ID_CAPTURE = 1,			// 抓拍组件（模块）
	COMPONENT_ID_DECODE  = 2,			// 解码组件
	COMPONENT_ID_CARD    = 3,			// 卡口分析组件
	COMPONENT_ID_VIO     = 4,			// 违章分析（事件检测）组件
	COMPONENT_ID_RECO    = 5, 			// 车牌识别组件
	COMPONENT_ID_MAX
};

enum LAMP_DETECTOR_MSG	// 红绿灯信号
{
	LAMP_DETECTOR_MSG_UNKNOWN   = -1,
	LAMP_DETECTOR_MSG_RGY       = 1,
	LAMP_DETECTOR_MSG_HEART     = 2
};

enum LAMP_STATE			// 红绿灯状态
{
	LAMP_STATE_UNKNOWN   = -1,
	LAMP_STATE_GREEN     = 0,
	LAMP_STATE_RED       = 1
};

enum DIRECTION			// 导向方向
{
	DIRECTION_UNKNOWN     = 0x0,
	DIRECTION_LEFT        = 0x1,
	DIRECTION_STRAIGHT    = 0x1 << 4,
	DIRECTION_RIGHT       = 0x1 << 8,
	DIRECTION_UTURN       = 0x1 << 12
};

enum PICTURE_FORM			// 图片合成方式
{
	PICTURE_FORM_UNKNOWN	= -1,
	PICTURE_FORM_3		= 1,	// 三张独立
	PICTURE_FORM_3PLUS1	= 2		// 3+1组合
};

enum FORBIDDEN_TYPE		// 禁令类型
{
	FORBIDDEN_TYPE_NONE   = 0,
	FORBIDDEN_TYPE_LEFT   = 0x1,
	FORBIDDEN_TYPE_STRAIGHT = 0x1 << 1,
	FORBIDDEN_TYPE_RIGHT  = 0x1 << 2,
	FORBIDDEN_TYPE_UTURN  = 0x1 << 3
};

enum VIOLATION_TYPE		// 交通违法类型
{
	VIOLATION_TYPE_UNKOWN            = 0x1 << 31, // 未知类型
	VIOLATION_TYPE_NONE              = 0x0,       // 正常行驶

	VIOLATION_TYPE_RED               = 0x1,       // 闯红灯
	VIOLATION_TYPE_CHANNEL           = 0x1 << 1,	// 违法变道
	VIOLATION_TYPE_SLINE             = 0x1 << 2,  // 压单实线
	VIOLATION_TYPE_DLINE             = 0x1 << 3,  // 压双实线
	VIOLATION_TYPE_CONVERSE          = 0x1 << 4,  // 逆行
	VIOLATION_TYPE_OVERSPEED         = 0x1 << 5,  // 超速
};

struct RPLATE
{
    char result[16];
    int time;

    double fCreditAll, fCredit[16];
    unsigned int charColor, bkColor;

    int index;
    int aveGrayScale;

    int plateWidth;
    int plateHeight;

    int plateLeft;
    int plateTop;
};

#endif /* G_COMMON_H_ */
